import 'package:bruno/bruno.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_shipper/SendGoods/TMSOrlder/DispatchedDetial.dart';
import 'package:sph_shipper/http/api.dart';

import '../../AppConfig/Config.dart';
import '../../AppConfig/RouteAct.dart';
import '../../Main/MyWallet/DepositManagement.dart';
import '../../http/NoLoadingGetApi.dart';
import 'TMSOrderDetial.dart';

class DispatchedList extends StatefulWidget {
  const DispatchedList({super.key});

  @override
  State<DispatchedList> createState() => _DispatchedListState();
}

class _DispatchedListState extends State<DispatchedList> {
  List dataList=[];
  int pageNum=1;
  String timeTitle="下单时间";
  String createStratTime="";
  String createEndTime="";
  String orderNumStr="";
  String deliveryNum="";
  String dispatcher="";
  String customerName="";
  int chooseType=-1;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getOrderListAction();
  }
  void getOrderListAction(){
    NoLoadinggetApiManager.getData(
      context,
      "api/tms/waybill/page",
      {
        "current":pageNum,
        "size":20,
        "customerOrderNum":orderNumStr,
        "customerLoadOrderNum":deliveryNum,
        "searchKey":customerName,
      },
          (responseData) async {
        dataList=responseData['data']['records'];
      },
    );
  }
  void onReachBottom() {
    setState(() {
      pageNum=pageNum+1;

    });

  }



  void _onRefresh() {
    setState(() {
      pageNum=1;

    });

    // 在这里可以执行加载更多数据的逻辑
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return ListView(
      children: [
        Container(
          padding: EdgeInsets.only(top: 4.h,left: 10.w,right: 10.w),
          height: 35.h,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              GestureDetector(
                child: Row(
                    children: [
                      Text(timeTitle,style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                      Icon(Icons.keyboard_arrow_down,color: MyColors.authTipColor,size: 14,),
                    ],),
                onTap: ()async{
                  final result= await showModalBottomSheet(
                    context: context,
                    builder: (BuildContext context) {
                      return dataTimeSheet(type: 1,
                      );
                    },
                  );
                  if (result != null) {
                    setState(() {
                      timeTitle=result;
                    });
                  }
                },
              ),
              GestureDetector(
                child:  Row(
                  children: [
                    Text("筛选",style: TextStyle(color: Colors.black),),
                    Image.asset("lib/Images/OrderList/找货筛选icon.png",width: 15.w,height: 15.h,)
                  ],
                ),
                onTap: ()async{
                 final result=await Navigator.push( context, FadeRoute(page:DispatchedRight()));
                 setState(() {
                   createStratTime=result[0].substring(0, 10);
                   createEndTime=result[0].substring(timeTitle.length - 10, timeTitle.length);
                   dispatcher=result[5];
                   orderNumStr=result[3];
                   deliveryNum=result[4];
                   customerName=result[2];
                  if( result[1].contains("待发车"))
                    chooseType=0;
                   if( result[1].contains("运输中"))
                     chooseType=0;
                   if( result[1].contains("已送达"))
                     chooseType=0;
                   if( result[1].contains("已回单"))
                     chooseType=4;
                 });
                 getOrderListAction();
                },
              )
            ],
          ),
        ),
        Container(
          height: screenSize.height-140.h,
          child:       EasyRefresh(
              header:
              ClassicHeader(
                dragText: '下拉刷新',
                armedText: '准备释放',
                readyText: '加载中...',
                processingText: '加载中...',
                processedText: '刷新成功',
                noMoreText: '暂无更多',
                failedText: '刷新失败',
                messageText: '刷新时间 %T',
              ),
              footer: ClassicFooter(
                dragText: '加载更多',
                armedText: '准备释放',
                readyText: '加载中...',
                processingText: '加载中...',
                processedText: '加载成功',
                noMoreText: '暂无更多',
                failedText: '加载失败',
                messageText: '加载时间 %T',
              ),
              onRefresh: _onRefresh,
              onLoad:dataList.length>pageNum*20-1?onReachBottom:null,
              child:
              Container(

                  color: Color.fromRGBO(248, 248, 248, 1),
                  child:  ListView(

                      children: [
                        Container(
                            // margin: EdgeInsets.only(top: 4.h),
                            height:screenSize.height-200.h,
                            child:
                            dataList.isEmpty?
                            BrnAbnormalStateWidget(
                              img: Image.asset(
                                'lib/Images/OrderList/找货暂无货源.png',
                                scale: 3.0,
                              ),
                              content: '您的账号暂无订单',
                            ): ListView.separated(
                              shrinkWrap:true,
                              itemCount: 3,
                              itemBuilder: (BuildContext context, int index) {
                                return GestureDetector(
                                  onTap: (){ Navigator.push( context, FadeRoute(page:DispatchedDetial()));},
                                  child: Container(
                                    margin: EdgeInsets.only(left: 8.w,right: 8.w),
                                    padding: EdgeInsets.only(top: 10.h,right: 10.w,bottom: 10.h,left: 10.w),
                                    decoration: BoxDecoration(
                                        color: Colors.white,
                                        borderRadius: BorderRadius.all(Radius.circular(10))),
                                    child: Column(
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      children: [
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(dataList[index]['id'],style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                                            Text(dataList[index]['createTime'],style: TextStyle(color: MyColors.textColor,fontSize: 11.sp),),
                                          ],
                                        ),
                                        SizedBox(height: 4.h,),
                                        Text(dataList[index]['status']==1?"未发车":dataList[index]['status']==2?"已发车":dataList[index]['status']==3?"已对账":"已回单",style: TextStyle(color: Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600),),
                                        SizedBox(height: 4.h,),
                                        Row(
                                          children: [
                                            Image.asset("lib/Images/OrderList/装icon.png",width: 13.w,height: 13.h,),
                                            SizedBox(width: 4.w,),
                                            Container(
                                              constraints: BoxConstraints(
                                                maxWidth:screenSize.width-60.w,
                                              ),
                                              child:   Text(dataList[index]['loadPlaceInfo'][0]['address'],style: TextStyle(color: Colors.black,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                            ),

                                          ],
                                        ),
                                        Image.asset("lib/Images/OrderList/垂直虚线.png",width:13.w ,height:8.h,),
                                        Row(
                                          children: [
                                            Image.asset("lib/Images/OrderList/卸icon.png",width: 13.w,height: 13.h,),
                                            SizedBox(width: 4.w,),
                                            Container(
                                              constraints: BoxConstraints(
                                                maxWidth:screenSize.width-60.w,
                                              ),
                                              child:   Text(dataList[index]['unloadPlaceInfo'][0]['address'],style: TextStyle(color: Colors.black,fontSize: 13.sp),overflow: TextOverflow.ellipsis,),
                                            ),

                                          ],
                                        ),
                                        SizedBox(height: 4.h,),
                                        Text("${dataList[index]['cargoInfo'][0]['name']}丨${dataList[index]['cargoInfo'][0]['packageType']}",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                                        SizedBox(height: 4.h,),
                                        Text("${dataList[index]['driverName']}丨${dataList[index]['driverPhone']}丨${dataList[index]['vehicleNum']}",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                                        Divider(height: 20.h,color: MyColors.backgreyColor,),

                                        Row(
                                          mainAxisAlignment: MainAxisAlignment.end,
                                          children: [
                                          if(dataList[index]['status']==1)
                                            GestureDetector(
                                              child:   BrnTagCustom.buildBorderTag(
                                                tagText: '发运',
                                                textColor:  MyColors.themeColor,
                                                borderColor: MyColors.themeColor,
                                                borderWidth: 1,
                                                fontSize: 13.sp,
                                                tagBorderRadius:BorderRadius.all(Radius.circular(30)),
                                                textPadding: EdgeInsets.only(left: 10.w,right: 10.w,top: 2.h,bottom: 2.h),
                                              ),
                                              onTap: (){
                                                ApiManager.postData(
                                                  context,
                                                  'api/user/waybill/status',
                                                  {
                                                    "waybillIdList":dataList[index]['id'],
                                                    "status":"STARTED",
                                                  },
                                                      (responseData) {
                                                        BrnToast.show("操作成功", context);
                                                        getOrderListAction();
                                                  },
                                                );
                                              },
                                            ),
                                            if(dataList[index]['status']==2)
                                            SizedBox(width: 4.w,),
                                            if(dataList[index]['status']==2)
                                            GestureDetector(
                                              child:   BrnTagCustom.buildBorderTag(
                                                tagText: '到达',
                                                textColor:  MyColors.themeColor,
                                                borderColor: MyColors.themeColor,
                                                borderWidth: 1,
                                                fontSize: 13.sp,
                                                tagBorderRadius:BorderRadius.all(Radius.circular(30)),
                                                textPadding: EdgeInsets.only(left: 10.w,right: 10.w,top: 2.h,bottom: 2.h),
                                              ),
                                              onTap: (){
                                                ApiManager.postData(
                                                  context,
                                                  'api/user/waybill/status',
                                                  {
                                                    "waybillIdList":dataList[index]['id'],
                                                    "status":"ENDED",
                                                  },
                                                      (responseData) {
                                                    BrnToast.show("操作成功", context);
                                                    getOrderListAction();
                                                  },
                                                );
                                              },
                                            ),
                                            if(dataList[index]['status']==3)
                                            SizedBox(width: 4.w,),
                                            if(dataList[index]['status']==3)
                                            GestureDetector(
                                              child:   BrnTagCustom.buildBorderTag(
                                                tagText: '回单',
                                                textColor:  MyColors.themeColor,
                                                borderColor: MyColors.themeColor,
                                                borderWidth: 1,
                                                fontSize: 13.sp,
                                                tagBorderRadius:BorderRadius.all(Radius.circular(30)),
                                                textPadding: EdgeInsets.only(left: 10.w,right: 10.w,top: 2.h,bottom: 2.h),
                                              ),
                                              onTap: (){
                                                ApiManager.postData(
                                                  context,
                                                  'api/user/waybill/status',
                                                  {
                                                    "waybillIdList":dataList[index]['id'],
                                                    "status":"RETURNED",
                                                  },
                                                      (responseData) {
                                                    BrnToast.show("操作成功", context);
                                                    getOrderListAction();
                                                  },
                                                );
                                              },
                                            ),
                                          ],
                                        )
                                      ],
                                    ),
                                  ),
                                );
                              },  separatorBuilder: (context, index) { //自定义分割线
                              return   Container(
                                height: 8.h,
                              );
                            },
                            )
                        )
                      ]
                  )
              )
          ),
        ),

      ],
    );

  }
}
class DispatchedRight extends StatefulWidget {
  const DispatchedRight({super.key});

  @override
  State<DispatchedRight> createState() => _DispatchedRightState();
}

class _DispatchedRightState extends State<DispatchedRight> {
  double _startX=0;
  String customerName="";
  String timerStr="选择日期范围";
  String orderNumStr="";
  String deliveryNum="";
  String dispatcher="";
  List orderTypeTitle=["待发车","运输中","已送达","已回单"];
  String chooseType="";
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return GestureDetector(
      onHorizontalDragStart: (details) {
        _startX = details.globalPosition.dx;
      },
      onHorizontalDragUpdate: (details) {
        // Calculate the distance moved
        double deltaX = details.globalPosition.dx - _startX;
        if (deltaX > 50) {
          Navigator.of(context).pop();
        }
      },
      child: Drawer(
        width: screenSize.width,
        child: Row(
          children: [
            GestureDetector(
              child:   Container(
                width: 40.w,
                height: screenSize.height,
                color: MyColors.backgreyColor,
              ),
              onTap: (){
                Navigator.pop(context);
              },
            ),
      Container(
        color: Colors.white,
        padding: EdgeInsets.only(top: 50.h,left: 10.w,right: 10.w,bottom: 30.h),
        width: screenSize.width-40.w,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text("创建时间",style: TextStyle(color:Colors.black,fontSize: 14.sp),),
            SizedBox(height: 10.h,),
            BrnSmallOutlineButton(
              title: timerStr,
              lineColor: MyColors.authTipColor,
              textColor:timerStr=="选择日期范围"? MyColors.authTipColor:MyColors.textColor,
              fontSize: 13.sp,
              width: screenSize.width-100.w,
              radius: 10,
              onTap: () async{
                final result= await showModalBottomSheet(
                  context: context,
                  builder: (BuildContext context) {
                    return dataTimeSheet(type: 1,
                    );
                  },
                );
                if (result != null) {

                  setState(() {
                    timerStr=result;
                  });
                }
              },
            ),
            Divider(height: 16.h,color: MyColors.backgreyColor,),
            Text("运单状态",style: TextStyle(color:Colors.black,fontSize: 14.sp),),
            SizedBox(height: 8.h,),
            Container(
              padding: EdgeInsets.only(left: 20.w),
              child:  Wrap(
                spacing: 8.w, // 两个Container之间的水平间距
                runSpacing: 5.h, // 行与行之间的垂直间距
                children: orderTypeTitle.map((length) {
                  bool isSelected = chooseType.contains(length)??false;
                  return GestureDetector(
                    onTap: () {
                      // 处理点击事件
                      setState(() {
                        if (isSelected) {
                          // 如果已经被选中，则移除
                          chooseType="";
                        } else  {
                          // 如果未被选中且未达到最大选择数量，则添加
                          chooseType=length;

                        }
                      });
                    },
                    child: Container(
                      width: (screenSize.width-60.w)/4, // Container宽度
                      height: 25.h, // Container高度，使其成为正方形
                      decoration: BoxDecoration(
                        color: isSelected ? Color.fromRGBO(251, 236, 228, 1) : MyColors.backgreyColor, // 根据状态决定颜色
                        borderRadius: BorderRadius.circular(3.0), // 设置Container的圆角
                      ),
                      child: Center(
                        child: Text(
                          length,
                          style: TextStyle(
                            fontSize: 14.sp,
                            color: isSelected ?MyColors.themeColor:Colors.black, // 文字颜色为白色
                          ),
                        ),
                      ),
                    ),
                  );
                }).toList(),
              ),
            ),
            GestureDetector(
              child: Container(
                margin: EdgeInsets.only(top: 10.h),
                width: screenSize.width-60.w,
                child:  Row(

                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("客户名称",style: TextStyle(color:Colors.black,fontSize: 14.sp),),
                    Row(
                      children: [
                        customerName==""?
                        Text("请输入",style: TextStyle(color: MyColors.hintColor,fontSize: 14.sp),)
                            :Text(customerName,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 14,),
                      ],
                    )
                  ],
                ),
              ),
              onTap: (){
                showModalBottomSheet(
                  context: context,
                  isDismissible: false,
                  builder: (BuildContext context) {
                    return Container(
                      padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 15.h),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(6)),
                        color: Colors.white,
                      ),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                onTap: (){
                                  setState(() {
                                    customerName="";
                                  });

                                  Navigator.pop(context);
                                },
                              ),
                              Text("客户名称",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                              GestureDetector(
                                child:Text("确定",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                onTap: (){
                                  Navigator.pop(context);
                                },
                              ),
                            ],
                          ),
                          SizedBox(height: 10.h,),
                          Container(
                            height: 35.h,
                            width: screenSize.width-40.w,
                            alignment: Alignment.centerLeft,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.all(Radius.circular(6)),
                              color: MyColors.backgreyColor,
                            ),
                            child:TextField(
                              style: TextStyle(color: Colors.black,fontSize: 14.sp),
                              keyboardType: TextInputType.number,
                              decoration: InputDecoration(
                                filled: true,
                                fillColor: Color.fromRGBO(248, 248, 248, 1),
                                hintText: "请输入客户名称",
                                //边框
                                focusedBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Color.fromRGBO(248, 248, 248, 1))),
                                enabledBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color:Color.fromRGBO(248, 248, 248, 1),)),
                                hintStyle: TextStyle(
                                  color: Color.fromRGBO(183, 183, 183, 1),
                                  fontSize:  MyFontSizes.commonrText.sp,
                                ),
                              ),
                              onChanged: (value) {
                                setState(() {
                                  customerName=value;
                                });
                              },

                            ),
                          ),
                        ],
                      ),

                    );
                  },
                );
              },

                ),
            Divider(height: 16.h,color: MyColors.backgreyColor,),
            GestureDetector(
              child: Container(
                width: screenSize.width-60.w,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("客户订单号",style: TextStyle(color:Colors.black,fontSize: 14.sp),),
                    Row(
                      children: [
                        orderNumStr==""?
                        Text("请输入",style: TextStyle(color: MyColors.hintColor,fontSize: 14.sp),)
                            :Text(orderNumStr,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 14,),
                      ],
                    )
                  ],
                ),
              ),
              onTap: (){
                showModalBottomSheet(
                  context: context,
                  isDismissible: false,
                  builder: (BuildContext context) {
                    return Container(
                      padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 15.h),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(6)),
                        color: Colors.white,
                      ),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                onTap: (){
                                  setState(() {
                                    orderNumStr="";
                                  });

                                  Navigator.pop(context);
                                },
                              ),
                              Text("客户订单号",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                              GestureDetector(
                                child:Text("确定",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                onTap: (){
                                  Navigator.pop(context);
                                },
                              ),
                            ],
                          ),
                          SizedBox(height: 10.h,),
                          Container(
                            height: 35.h,
                            width: screenSize.width-40.w,
                            alignment: Alignment.centerLeft,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.all(Radius.circular(6)),
                              color: MyColors.backgreyColor,
                            ),
                            child:TextField(
                              style: TextStyle(color: Colors.black,fontSize: 14.sp),
                              keyboardType: TextInputType.number,
                              decoration: InputDecoration(
                                filled: true,
                                fillColor: Color.fromRGBO(248, 248, 248, 1),
                                hintText: "请输入客户订单号",
                                //边框
                                focusedBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Color.fromRGBO(248, 248, 248, 1))),
                                enabledBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color:Color.fromRGBO(248, 248, 248, 1),)),
                                hintStyle: TextStyle(
                                  color: Color.fromRGBO(183, 183, 183, 1),
                                  fontSize:  MyFontSizes.commonrText.sp,
                                ),
                              ),
                              onChanged: (value) {
                                setState(() {
                                  customerName=value;
                                });
                              },

                            ),
                          ),
                        ],
                      ),

                    );
                  },
                );
              },

            ),
            Divider(height: 16.h,color: MyColors.backgreyColor,),
            GestureDetector(
              child: Container(
                width: screenSize.width-60.w,
                child:  Row(

                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("客户提货单号",style: TextStyle(color:Colors.black,fontSize: 14.sp),),
                    Row(
                      children: [
                        deliveryNum==""?
                        Text("请输入",style: TextStyle(color: MyColors.hintColor,fontSize: 14.sp),)
                            :Text(deliveryNum,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 14,),
                      ],
                    ),
                  ],
                ),
              ),
              onTap: (){
                showModalBottomSheet(
                  context: context,
                  isDismissible: false,
                  builder: (BuildContext context) {
                    return Container(
                      padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 15.h),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(6)),
                        color: Colors.white,
                      ),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                onTap: (){
                                  setState(() {
                                    deliveryNum="";
                                  });

                                  Navigator.pop(context);
                                },
                              ),
                              Text("客户提货单号",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                              GestureDetector(
                                child:Text("确定",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                onTap: (){
                                  Navigator.pop(context);
                                },
                              ),
                            ],
                          ),
                          SizedBox(height: 10.h,),
                          Container(
                            height: 35.h,
                            width: screenSize.width-40.w,
                            alignment: Alignment.centerLeft,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.all(Radius.circular(6)),
                              color: MyColors.backgreyColor,
                            ),
                            child:TextField(
                              style: TextStyle(color: Colors.black,fontSize: 14.sp),
                              keyboardType: TextInputType.number,
                              decoration: InputDecoration(
                                filled: true,
                                fillColor: Color.fromRGBO(248, 248, 248, 1),
                                hintText: "请输入客户提货单号",
                                //边框
                                focusedBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Color.fromRGBO(248, 248, 248, 1))),
                                enabledBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color:Color.fromRGBO(248, 248, 248, 1),)),
                                hintStyle: TextStyle(
                                  color: Color.fromRGBO(183, 183, 183, 1),
                                  fontSize:  MyFontSizes.commonrText.sp,
                                ),
                              ),
                              onChanged: (value) {
                                setState(() {
                                  customerName=value;
                                });
                              },

                            ),
                          ),
                        ],
                      ),

                    );
                  },
                );
              },

            ),
            Divider(height: 16.h,color: MyColors.backgreyColor,),
            GestureDetector(
              child: Container(
                width: screenSize.width-60.w,
                child:  Row(

                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("调度员",style: TextStyle(color:Colors.black,fontSize: 14.sp),),
                    Row(
                      children: [
                        dispatcher==""?
                        Text("请输入",style: TextStyle(color: MyColors.hintColor,fontSize: 14.sp),)
                            :Text(dispatcher,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                        Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 14,),
                      ],
                    ),
                  ],
                ),
              ),
              onTap: (){
                showModalBottomSheet(
                  context: context,
                  isDismissible: false,
                  builder: (BuildContext context) {
                    return Container(
                      padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 15.h),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(6)),
                        color: Colors.white,
                      ),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                child: Text("取消",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                onTap: (){
                                  setState(() {
                                    dispatcher="";
                                  });

                                  Navigator.pop(context);
                                },
                              ),
                              Text("调度员",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                              GestureDetector(
                                child:Text("确定",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                onTap: (){
                                  Navigator.pop(context);
                                },
                              ),
                            ],
                          ),
                          SizedBox(height: 10.h,),
                          Container(
                            height: 35.h,
                            width: screenSize.width-40.w,
                            alignment: Alignment.centerLeft,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.all(Radius.circular(6)),
                              color: MyColors.backgreyColor,
                            ),
                            child:TextField(
                              style: TextStyle(color: Colors.black,fontSize: 14.sp),
                              keyboardType: TextInputType.number,
                              decoration: InputDecoration(
                                filled: true,
                                fillColor: Color.fromRGBO(248, 248, 248, 1),
                                hintText: "请输入调度员名称",
                                //边框
                                focusedBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Color.fromRGBO(248, 248, 248, 1))),
                                enabledBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color:Color.fromRGBO(248, 248, 248, 1),)),
                                hintStyle: TextStyle(
                                  color: Color.fromRGBO(183, 183, 183, 1),
                                  fontSize:  MyFontSizes.commonrText.sp,
                                ),
                              ),
                              onChanged: (value) {
                                setState(() {
                                  dispatcher=value;
                                });
                              },

                            ),
                          ),
                        ],
                      ),

                    );
                  },
                );
              },

            ),
            Divider(height: 16.h,color: MyColors.backgreyColor,),

            Container(
              margin: EdgeInsets.only(top: 50.h),
              height: 30.h,
              child: Row(
                children: [
                  BrnSmallOutlineButton(
                    title: '重置',
                    lineColor: MyColors.themeColor,
                    textColor: MyColors.themeColor,
                    fontSize: 14.sp,
                    width: (screenSize.width-70.w)/2,
                    radius: 30,
                    onTap: () {
                      setState(() {
                        chooseType="";
                        customerName="";
                        timerStr="选择日期范围";
                         orderNumStr="";
                        deliveryNum="";
                        dispatcher="";
                      });
                    },
                  ),
                  SizedBox(width: 10.w,),
                  BrnSmallMainButton(
                    title: '确定',
                    bgColor: MyColors.themeColor,
                    textColor: Colors.white,
                    radius: 30,
                    fontSize: 14.sp,
                    width: (screenSize.width-70.w)/2,
                    onTap: () {
                      Navigator.pop(context,[timerStr,chooseType,customerName,orderNumStr,deliveryNum,dispatcher]);
                    },
                  )
                ],
              ),
            )
          ],
        ),
      ),
          ],
        ),
      ),
    );
  }
}
